package com.headcaselabs.orchestra;

import java.util.LinkedList;

import com.headcaselabs.queue.SQSUtils;
import com.headcaselabs.work.TestUnitOfWork;
import com.headcaselabs.work.UnitOfWork;

public class MessageInjector {
	
private Configuration conf;
	
	private SQSUtils sqsUtils;
	public MessageInjector(SQSUtils sqsUtils, Configuration conf) {
		this.conf = conf;
		this.sqsUtils = sqsUtils;
	}
	
	public void addMessage(UnitOfWork job) {
		System.out.println("Sent message with id:"+sqsUtils.sendJob(job));
	}
	
	
	public static void main(String args[]) {
		String file = args[0];
		Configuration conf = Configuration.getConfiguration(file);
		MessageInjector mi = new MessageInjector(new SQSUtils(conf),conf);
		LinkedList<UnitOfWork> jobs = new LinkedList<UnitOfWork>();
		int multi = 10000;
		for (int i = 0; i < 1; i++) {
			UnitOfWork uof = new TestUnitOfWork(10000,"id:100000",2000);
			//uof.setMax_time(conf.getQueueExpectedProcessingTimes().get(0)*2);
			uof.setId("blahhhh.232030238");
			uof.setCreationTime(System.currentTimeMillis());
			System.out.println("Sending job in Queue:"+conf.getQueues().get(0));
			uof.setQueueName(conf.getQueues().get(2));
			jobs.add(uof);
		}
		for (UnitOfWork j : jobs) {
			mi.addMessage(j);
		}
		
		
	}
 
}
